//
//  ActivityListTableViewCell.m
//  豆瓣(阿黄)
//
//  Created by dllo on 15/10/27.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ActivityListTableViewCell.h"
#import "UIImageView+WebCache.h"

@implementation ActivityListTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatView];
    }
    return self;
}


- (void)creatView{

    [self addSubview:self.blueImageView];
    [self.blueImageView release];
    
    [self.blueImageView addSubview:self.titleLabel];
    [self.titleLabel release];
    
    [self.blueImageView addSubview:self.whiteImageView];
    [self.whiteImageView release];
    
    [self.whiteImageView addSubview:self.timeImageView];
    [self.timeImageView release];
    
    [self.whiteImageView addSubview:self.addressImageView];
    [self.addressImageView release];
    
    [self.whiteImageView addSubview:self.typeImageView];
    [self.typeImageView release];
    
    [self.whiteImageView addSubview:self.likeLabel];
    [self.likeLabel release];
    
    [self.whiteImageView addSubview:self.likeText];
    [self.likeText release];
    
    [self.whiteImageView addSubview:self.inLabel];
    [self.inLabel release];
    
    [self.whiteImageView addSubview:self.inText];
    [self.inText release];
    
    [self.whiteImageView addSubview:self.timeLabel1];
    [self.timeLabel1 release];
    
    [self.whiteImageView addSubview:self.timeLabel2];
    [self.timeLabel2 release];
    
    [self.whiteImageView addSubview:self.addressLabel];
    [self.addressLabel release];
    
    [self.whiteImageView addSubview:self.typeLabel];
    [self.typeLabel release];
    
    [self.whiteImageView addSubview:self.picImageView];
    [self.picImageView release];

    
}

-(UIImageView *)picImageView{

    if (_picImageView == nil) {
        self.picImageView = [[UIImageView alloc] initWithFrame:CGRectMake(245, 5, 100, 115)];
        self.picImageView.backgroundColor = [UIColor blackColor];
    }
    return _picImageView;
}

-(UILabel *)typeLabel{

    if (_typeLabel == nil) {
        self.typeLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 63, 150, 30)];
        self.typeLabel.text = @"类型";
        self.typeLabel.font = [UIFont systemFontOfSize:15];
    }
    return _typeLabel;
}

-(UILabel *)addressLabel{

    if (_addressLabel == nil) {
        self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 33, 150, 30)];
        self.addressLabel.text = @"地址";
        self.addressLabel.font = [UIFont systemFontOfSize:15];
    }
    return _addressLabel;
}

-(UILabel *)timeLabel2{

    if (_timeLabel2 == nil) {
        self.timeLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(140, 3, 100, 30)];
        self.timeLabel2.text = @"时间";
        self.timeLabel2.font = [UIFont systemFontOfSize:12];
    }
    return _timeLabel2;
}

-(UILabel *)timeLabel1{
    
    if (_timeLabel1 == nil) {
        self.timeLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(40, 3, 100, 30)];
        self.timeLabel1.text = @"时间";
        self.timeLabel1.font = [UIFont systemFontOfSize:12];
    }
    return _timeLabel1;
}

-(UILabel *)inText{
    
    if (_inText == nil) {
        self.inText = [[UILabel alloc] initWithFrame:CGRectMake(185, 100, 50, 20)];
        self.inText.text = @"1645";
        self.inText.textColor = [UIColor redColor];
        self.inText.font = [UIFont systemFontOfSize:15];
    }
    return _inText;
}


-(UILabel *)inLabel{
    
    if (_inLabel == nil) {
        self.inLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 100, 50, 20)];
        self.inLabel.text = @"参加:";
        self.inLabel.font = [UIFont systemFontOfSize:15];
    }
    return _inLabel;
}


-(UILabel *)likeText{
    
    if (_likeText == nil) {
        self.likeText = [[UILabel alloc] initWithFrame:CGRectMake(90, 100, 50, 20)];
        self.likeText.text = @"1975";
        self.likeText.textColor = [UIColor redColor];
        self.likeText.font = [UIFont systemFontOfSize:15];
    }
    return _likeText;
}


-(UILabel *)likeLabel{

    if (_likeLabel == nil) {
        self.likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 100, 50, 20)];
        self.likeLabel.text = @"感兴趣:";
        self.likeLabel.font = [UIFont systemFontOfSize:15];
    }
    return _likeLabel;
}

-(UIImageView *)typeImageView{
    
    if (_typeImageView == nil) {
        self.typeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(7, 65, 25, 25)];
        self.typeImageView.image = [UIImage imageNamed:@"icon_catalog@2x.png"];
    }
    return _typeImageView;
}


-(UIImageView *)addressImageView{
    
    if (_addressImageView == nil) {
        self.addressImageView = [[UIImageView alloc] initWithFrame:CGRectMake(7, 35, 25, 25)];
        self.addressImageView.image = [UIImage imageNamed:@"icon_spot@2x.png"];
    }
    return _addressImageView;
}

-(UIImageView *)timeImageView{

    if (_timeImageView == nil) {
        self.timeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(7, 5, 25, 25)];
        self.timeImageView.image = [UIImage imageNamed:@"icon_date@2x.png"];
    }
    return _timeImageView;
}

-(UIImageView *)whiteImageView{

    if (_whiteImageView == nil) {
        self.whiteImageView = [[UIImageView alloc] initWithFrame:CGRectMake(2, 40, 351, 128)];
        self.whiteImageView.image = [UIImage imageNamed:@"bg_share_large@2x.png"];
    }
    return _whiteImageView;
}

-(UILabel *)titleLabel{

    if (_titleLabel == nil) {
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 3, 300, 40)];
        self.titleLabel.text = @"标题";
        self.titleLabel.font = [UIFont systemFontOfSize:21];
    }
    return _titleLabel;
}

-(UIImageView *)blueImageView{

    if (_blueImageView == nil) {
        self.blueImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 15, 355, 175)];
        self.blueImageView.image = [UIImage imageNamed:@"bg_eventlistcell@2x.png"];
    }
    return _blueImageView;
}

//- (void)sendData:(NSData *)data{
//
//    self.picImageView.image = [UIImage imageWithData:data];
//}

- (void)sendValue:(ActivityList *)activityL{

    self.titleLabel.text = activityL.title;
    self.timeLabel1.text = [activityL.begin_time substringFromIndex:5];
    self.timeLabel2.text = [activityL.end_time substringFromIndex:5];
    self.addressLabel.text = activityL.address;
    self.typeLabel.text = activityL.category_name;
    self.likeText.text = [NSString stringWithFormat:@"%@",activityL.wisher_count];
    self.inText.text = [NSString stringWithFormat:@"%@",activityL.participant_count];
    
    NSURL *url = [NSURL URLWithString:activityL.image_hlarge];
    [self.picImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHoderImage.png"]];
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
